package com.cmbchina.entity;

import java.math.BigDecimal;
import java.util.Objects;

public class Money { //转账金额

    private BigDecimal amount; //账户
    private Currency currency; //币种

    public Money(BigDecimal amount, Currency currency) {
        setAmount(amount);
        this.currency = currency;
    }

    public void setAmount(BigDecimal amount) {
        if(Objects.isNull(amount)){
            throw new IllegalArgumentException("amount cannot be null");
        }

        if(amount.compareTo(BigDecimal.ZERO) <= 0){
            throw new IllegalArgumentException("amount cannot be positive");
        }

        this.amount = amount;
    }

    public BigDecimal getAmount() {
        return amount;
    }

    public Currency getCurrency() {
        return currency;
    }

}
